using System.Data;
using Lutos.ORM;
using Lutos.EntityModel;

namespace Lutos.Portal
{
	public class PortalMapper : TableGateWay
	{
		public PortalMapper()
		{

		}

		public override DataTable NewTable()
		{
			return new PortalModel.Lx_PortalDataTable();
		}

		public Portal NewPortal()
		{
			PortalModel.Lx_PortalDataTable portalTable = new PortalModel.Lx_PortalDataTable();
			return new Portal(portalTable.NewRow());
		}

		public Portal GetPortalByName(string name)
		{
			PortalModel.Lx_PortalDataTable portalTable =
				LoadTableByWhere(string.Format("Portal_Name='{0}'", name)) as PortalModel.Lx_PortalDataTable;
			if (portalTable == null)
				return null;
			if (portalTable.Rows.Count > 0)
				return new Portal(portalTable.Rows[0]);
			else
				return null;
		}
	}
}